import { ref } from 'vue'
import { useRegistered } from './useEvents'

enum ETimer {
  TIME_OUR = 'Timeout',
  INTER_VAL = 'InterVal'
}

const useTimer = (event: Function, times: number) => {
  const timer = ref<number>(0)

  const add = () => {
    timer.value = setTimeout(event, times)
  }

  const remove = () => {
    clearTimeout(timer.value)
  }

  useRegistered(add, remove)
}

export default useTimer
